iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 3
2

前言

終於來到了操縱Docker的第一個章節,本章節將會教大家在各平台如何安裝Docker,並透過簡單的指令確認安裝成功與否。

Install docker

1. Linux

SET UP THE REPOSITORY

  • 更新apt-get:
$ sudo apt-get update
  • 安裝相關packages:
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
  • 新增 Docker 官方 GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • 透過以下指令去新增 stable 版本 repository.:
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

INSTALL DOCKER ENGINE - COMMUNITY

  • 更新apt:
$ sudo apt-get update
  • 安裝最新版本的 docker engine, docker command 以及 docker container:
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
  • 也可以透過下面指令安裝特定版本docker packages:
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containe

AFTER INSTALL ...

  • 利用以下指令測試安裝完成與否。
$ sudo docker -v

2. Mac

INSTALL THROUGH DOWNLOADING FILE

  • 點選下方指令下載docker-desktop並安裝:

https://hub.docker.com/editions/community/docker-ce-desktop-mac/

  • 點選stable按鈕下載docker-desktop:

https://ithelp.ithome.com.tw/upload/images/20200918/201297377uwuTW9RUc.png

INSTALL THROUGH THE COMMAND LINE

  • 請先檢查是否有brew。
$ brew -v
Homebrew 2.5.1
Homebrew/homebrew-core (git revision 3b988; last commit 2020-09-14)
  • 若尚未擁有brew的話,請用以下指令安裝它。
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  • 並進行更新
$ brew upgrade

3. Windows

INSTALL THROUGH DOWNLOADING FILE

  • 點選stable按鈕下載docker-desktop:

https://hub.docker.com/editions/community/docker-ce-desktop-windows/

  • 點選stable按鈕下載docker-desktop:

https://ithelp.ithome.com.tw/upload/images/20200918/201297375ankyLEGH6.png

Test docker

  • 利用以下指令測試安裝完成與否。
$ sudo docker -v
Docker version 19.03.8, build afacb8b

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:4cf9c47f86df71d48364001ede3a4fcd85ae80ce02ebad74156906caff5378bc
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

如果能成功執行docker -v 並且啟動hello-world的container就代表你成功了!

小結

恭喜大家順利的安裝完成Docker,邁出了踏入容器化殿堂的第一步。在下一章節當中,我們會先透過基本的Docker指令來讓大家玩轉Container,敬請期待。

https://ithelp.ithome.com.tw/upload/images/20200918/20129737pQMdfFfMYX.png

Reference

https://hub.docker.com/editions/community/


上一篇
Day-2 認識 Docker
下一篇
Day-4 初出Docker
系列文
Docker獸 究極進化 ~~ Kubernetes獸30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言